import { get, post, put, del, getWithArgs } from '../utils/xFetch2'

const newAPI = {
    // 发布
    release: params => {
        return post('api/v1/news', params)
    },
    list: params => {
        return getWithArgs('api/v1/news', params)
    },
    listById: ({ userId, pageSize, page }) => {
        return getWithArgs(`api/v1/news/getByUser/${userId}`, { pageSize: 999 })
    },
    auditList: params => {
        return getWithArgs(`api/v1/news/getNewsByState`, params)
    },
    detail: newId => {
        return getWithArgs(`api/v1/news/${newId}`)
    },
    myList: userId => {
        return getWithArgs(`api/v1/news/${userId}`)
    },
    delete: newId => {
        return del(`api/v1/news/${newId}`)
    },
    updateNew: (newId, params) => {
        return put(`api/v1/news/${newId}`, params)
    },
    updateState: params => {
        return put(`api/v1/news`, params)
    },
    relNews: params => {
        return getWithArgs('api/v1/news/list', params)
    }
    // weather: () => {
    //     return post('http://apis.juhe.cn/simpleWeather/query', {city: '杭州'})
    // }
}

export default newAPI
